home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / GenericFifo.h,v < prev    next >
Text File  |  1989-02-23  |  4KB  |  178 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.34.42;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.49.48;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     88.10.30.13.05.44;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     88.09.18.16.42.05;  author grunwald;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 3.2
  35. log
  36. @Start using Gnu library heaps for schedulers
  37. @
  38. text
  39. @// This may look like C code, but it is really -*- C++ -*-
  40. // 
  41. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  42. //
  43. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  44. //
  45. //
  46. // Define the following things:
  47. //    FIFO_NAME    -- the name of the fifo type
  48. //    FIFO_INDEX    -- the index type; defaults to unsigned short
  49. //    FIFO_ITEM    -- the type name for an item; should be typedefed
  50. //    FIFO_INDEX_NULL    -- the null value for the heap index; defaults to 65535
  51. //    FIFI_BASE_CLASS -- the base class for this derived FIFO
  52. //
  53.  
  54. #include "Awesime.h"
  55. #include "Generic.h"
  56.  
  57. #ifndef FIFO_INDEX
  58. #define FIFO_INDEX unsigned short
  59. #endif
  60.  
  61. #ifndef FIFO_INDEX_NULL
  62. #define FIFO_INDEX_NULL 0xffff
  63. #endif
  64.  
  65. #ifndef FIFO_BASE_CLASS
  66. #define FIFO_BASE_CLASS public Awesime
  67. #endif
  68.  
  69. typedef FIFO_ITEM GENERIC2(FIFO_NAME,Item);
  70. typedef FIFO_INDEX GENERIC2(FIFO_NAME,Index);
  71.  
  72. class FIFO_NAME : FIFO_BASE_CLASS {
  73.     
  74.     GENERIC2(FIFO_NAME,Item) *list;
  75.     GENERIC2(FIFO_NAME,Index) allocatedSize;
  76.     GENERIC2(FIFO_NAME,Index) listHead;
  77.     GENERIC2(FIFO_NAME,Index) listTail;
  78.  
  79.     char *pValid;
  80.     unsigned int listElements;
  81.     
  82.     inline GENERIC2(FIFO_NAME,Index) advance(GENERIC2(FIFO_NAME,Index) i) {
  83.     return( ((i+1) >= allocatedSize) ? (0) : (i+1) );
  84.     }
  85.     
  86. public:
  87.     
  88.     inline FIFO_NAME(int defaultLength = 0, bool xdebug = 0) : (xdebug) {
  89.     listHead = listTail = 0;
  90.     listElements = 0;
  91.     allocatedSize = 0;
  92.     list = 0;
  93.     pValid = 0;
  94.     if (defaultLength > 0) {
  95.         reSize(defaultLength);
  96.     }
  97.     }
  98.     
  99.     virtual ~FIFO_NAME();
  100.     
  101.     void reSize(int howMany);
  102.     
  103.     //
  104.     // Operations on the list
  105.     //
  106.     virtual void add(GENERIC2(FIFO_NAME,Item) *t);
  107.     virtual bool remove(GENERIC2(FIFO_NAME,Item) *item);
  108.     virtual bool removeIfFound(GENERIC2(FIFO_NAME,Item)* item);
  109.     
  110.     //
  111.     //    The next four members allow you to search a FIFO_NAME and mark
  112.     //    items as invalid. 
  113.     //
  114.     //    doStart initilizes the index and returns the first item in the list.
  115.     //    doNext moves to the next item and returns that item.
  116.     //    Both return a bool indicating whether the value in item has any
  117.     //    meaning. When bool=FALSE, you've searched everything.
  118.     //  Call doDone at the end to insure compatibility with subclasses.
  119.     //
  120.  
  121.     virtual bool doStart( GENERIC2(FIFO_NAME,Index) &index,
  122.              GENERIC2(FIFO_NAME,Item)* item);
  123.     virtual bool doDelete(GENERIC2(FIFO_NAME,Index) &index);
  124.     virtual bool doNext( GENERIC2(FIFO_NAME,Index) &index,
  125.             GENERIC2(FIFO_NAME,Item)* item);
  126.     virtual void doDone();
  127.     
  128.  
  129.     inline bool valid(GENERIC2(FIFO_NAME,Index) index) {
  130.     return ( pValid[index] );
  131.     }
  132.  
  133.     inline GENERIC2(FIFO_NAME,Item) & item(GENERIC2(FIFO_NAME,Index) i) {
  134.     return( list[i] );
  135.     }
  136.     inline GENERIC2(FIFO_NAME,Index) maxIndex() {
  137.     return(allocatedSize);
  138.     }
  139.  
  140.     virtual bool isEmpty();
  141.     virtual unsigned int size();
  142.     
  143.     virtual void classPrintOn(ostream& s);
  144.     virtual const char* classIsA();
  145. };
  146.  
  147. #undef FIFO_NAME
  148. #undef FIFO_ITEM
  149. #undef FIFO_KEY
  150. #undef FIFO_INDEX
  151. #undef FIFO_BASE_CLASS
  152. @
  153.  
  154.  
  155. 3.1
  156. log
  157. @Steay version
  158. @
  159. text
  160. @@
  161.  
  162.  
  163. 1.2
  164. log
  165. @*** empty log message ***
  166. @
  167. text
  168. @@
  169.  
  170.  
  171. 1.1
  172. log
  173. @Initial revision
  174. @
  175. text
  176. @d1 6
  177. @
  178.